package com.fm.base.database.domain;

import io.protostuff.LinkedBuffer;
import io.protostuff.ProtostuffIOUtil;
import io.protostuff.runtime.RuntimeSchema;
import org.apache.commons.codec.digest.DigestUtils;

public class DBLinkedDocumentEntity extends DBEntity<DBLinkedDocument> {
    private static RuntimeSchema<DBLinkedDocument> schema = RuntimeSchema.createFrom(DBLinkedDocument.class);

    public DBLinkedDocumentEntity() {
    }

    public DBLinkedDocumentEntity(DBLinkedDocument content) {
        super(content);
    }

    public DBLinkedDocumentEntity(Object id, DBLinkedDocument content) {
        super(id, content);
    }

    @Override
    public String computeMd5() {
        this.setMd5(DigestUtils.md5Hex(ProtostuffIOUtil.toByteArray(getContent(), schema, LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE))));
        return this.getMd5();
    }

    @Override
    public DBLinkedDocument getContent() {
        return this.content;
    }

    @Override
    public void setContent(DBLinkedDocument content) {
        this.content = content;
    }
}
